package logic

import (
	"context"

	"go-weixin/app/music/musicrpc/internal/domain"
	"go-weixin/app/music/musicrpc/internal/svc"
	"go-weixin/app/music/musicrpc/pb/proto/music"

	"github.com/zeromicro/go-zero/core/logx"
)

type MusicStreamDataLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
	musicDomain *domain.MusicDomain
}

func NewMusicStreamDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MusicStreamDataLogic {
	return &MusicStreamDataLogic{
		ctx:         ctx,
		svcCtx:      svcCtx,
		Logger:      logx.WithContext(ctx),
		musicDomain: domain.NewMusicDomain(*svcCtx.ChenDb),
	}
}

func (l *MusicStreamDataLogic) MusicStreamData(stream music.Music_MusicStreamDataServer) error {
	err := l.musicDomain.MusicFileStreamUpload(stream, l.svcCtx.Config.GoFast.DNS)
	if err != nil {
		return err
	}
	return nil
}
